package com.example.mylibrary.data;

import com.example.mylibrary.greendao.DaoSession;
import com.example.mylibrary.greendao.ItemGropDao;
import com.example.mylibrary.greendao.StudentItemDao;
import com.example.mylibrary.greendao.StudentItemGropDao;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.NotNull;
import org.greenrobot.greendao.annotation.ToOne;


/**
 * Created by Administrator on 2017/12/11.
 *  学生项目分组表
 */
@Entity
public class StudentItemGrop {
    //学生项目分组id
    @Id(autoincrement = true)
    private Long    studentItemGropID;

    //项目分组id
    @NotNull private long    itemGroupID;
    @ToOne(joinProperty = "itemGroupID")
    private ItemGrop itemGropid;

    //学生项目id
    @NotNull private long    studentItemID;
    @ToOne(joinProperty = "studentItemID")
    private StudentItem studentItemid;


    //道次
    private int    trackNo;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    /** Used for active entity operations. */
    @Generated(hash = 1697152292)
    private transient StudentItemGropDao myDao;


    @Generated(hash = 1894674712)
    public StudentItemGrop(Long studentItemGropID, long itemGroupID,
            long studentItemID, int trackNo) {
        this.studentItemGropID = studentItemGropID;
        this.itemGroupID = itemGroupID;
        this.studentItemID = studentItemID;
        this.trackNo = trackNo;
    }


    @Generated(hash = 186129125)
    public StudentItemGrop() {
    }


    public Long getStudentItemGropID() {
        return this.studentItemGropID;
    }


    public void setStudentItemGropID(Long studentItemGropID) {
        this.studentItemGropID = studentItemGropID;
    }


    public long getItemGroupID() {
        return this.itemGroupID;
    }


    public void setItemGroupID(long itemGroupID) {
        this.itemGroupID = itemGroupID;
    }


    public long getStudentItemID() {
        return this.studentItemID;
    }


    public void setStudentItemID(long studentItemID) {
        this.studentItemID = studentItemID;
    }


    public int getTrackNo() {
        return this.trackNo;
    }


    public void setTrackNo(int trackNo) {
        this.trackNo = trackNo;
    }


    @Generated(hash = 848342219)
    private transient Long itemGropid__resolvedKey;


    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1807936421)
    public ItemGrop getItemGropid() {
        long __key = this.itemGroupID;
        if (itemGropid__resolvedKey == null
                || !itemGropid__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            ItemGropDao targetDao = daoSession.getItemGropDao();
            ItemGrop itemGropidNew = targetDao.load(__key);
            synchronized (this) {
                itemGropid = itemGropidNew;
                itemGropid__resolvedKey = __key;
            }
        }
        return itemGropid;
    }


    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1483288037)
    public void setItemGropid(@NotNull ItemGrop itemGropid) {
        if (itemGropid == null) {
            throw new DaoException(
                    "To-one property 'itemGroupID' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.itemGropid = itemGropid;
            itemGroupID = itemGropid.getItemGropID();
            itemGropid__resolvedKey = itemGroupID;
        }
    }


    @Generated(hash = 1651737934)
    private transient Long studentItemid__resolvedKey;


    /** To-one relationship, resolved on first access. */
    @Generated(hash = 196640674)
    public StudentItem getStudentItemid() {
        long __key = this.studentItemID;
        if (studentItemid__resolvedKey == null
                || !studentItemid__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            StudentItemDao targetDao = daoSession.getStudentItemDao();
            StudentItem studentItemidNew = targetDao.load(__key);
            synchronized (this) {
                studentItemid = studentItemidNew;
                studentItemid__resolvedKey = __key;
            }
        }
        return studentItemid;
    }


    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 243295573)
    public void setStudentItemid(@NotNull StudentItem studentItemid) {
        if (studentItemid == null) {
            throw new DaoException(
                    "To-one property 'studentItemID' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.studentItemid = studentItemid;
            studentItemID = studentItemid.getStudentItemID();
            studentItemid__resolvedKey = studentItemID;
        }
    }


    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }


    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }


    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }


    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 276055574)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getStudentItemGropDao() : null;
    }

}
